package com.zzyl.nursing.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zzyl.common.core.domain.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zzyl.common.annotation.Log;
import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.common.enums.BusinessType;
import com.zzyl.nursing.domain.NursingProjectPlan;
import com.zzyl.nursing.service.INursingProjectPlanService;
import com.zzyl.common.utils.poi.ExcelUtil;
import com.zzyl.common.core.page.TableDataInfo;


/**
 * 护理计划和项目关联Controller
 * 
 * @author zhangyan
 * @date 2025-05-23
 */
@RestController
@RequestMapping("/nursing/projectPlan")
@Api(tags = "护理计划和项目关联")
public class NursingProjectPlanController extends BaseController
{
    @Autowired
    private INursingProjectPlanService nursingProjectPlanService;

    /**
     * 查询护理计划和项目关联列表
     */
    @PreAuthorize("@ss.hasPermi('nursing:projectPlan:list')")
    @GetMapping("/list")
    @ApiOperation("查询护理计划和项目关联列表")
    public TableDataInfo<NursingProjectPlan> list(NursingProjectPlan nursingProjectPlan)
    {
        startPage();
        LambdaQueryWrapper<NursingProjectPlan> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        //todo 补充条件
        List<NursingProjectPlan> list = nursingProjectPlanService.list(lambdaQueryWrapper);
        return getDataTable(list);
    }

    /**
     * 导出护理计划和项目关联列表
     */
    @ApiOperation("导出护理计划和项目关联列表")
    @PreAuthorize("@ss.hasPermi('nursing:projectPlan:export')")
    @Log(title = "护理计划和项目关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NursingProjectPlan nursingProjectPlan)
    {
        LambdaQueryWrapper<NursingProjectPlan> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        //todo 补充条件
        List<NursingProjectPlan> list = nursingProjectPlanService.list(lambdaQueryWrapper);
        ExcelUtil<NursingProjectPlan> util = new ExcelUtil<NursingProjectPlan>(NursingProjectPlan.class);
        util.exportExcel(response, list, "护理计划和项目关联数据");
    }

    /**
     * 获取护理计划和项目关联详细信息
     */
    @ApiOperation("获取护理计划和项目关联详细信息")
    @PreAuthorize("@ss.hasPermi('nursing:projectPlan:query')")
    @GetMapping(value = "/{id}")
    public R<NursingProjectPlan> getInfo(@PathVariable("id") Integer id)
    {
        return R.ok(nursingProjectPlanService.getById(id));
    }

    /**
     * 新增护理计划和项目关联
     */
    @ApiOperation("新增护理计划和项目关联")
    @PreAuthorize("@ss.hasPermi('nursing:projectPlan:add')")
    @Log(title = "护理计划和项目关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NursingProjectPlan nursingProjectPlan)
    {
        return toAjax(nursingProjectPlanService.save(nursingProjectPlan));
    }

    /**
     * 修改护理计划和项目关联
     */
    @ApiOperation("修改护理计划和项目关联")
    @PreAuthorize("@ss.hasPermi('nursing:projectPlan:edit')")
    @Log(title = "护理计划和项目关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NursingProjectPlan nursingProjectPlan)
    {
        return toAjax(nursingProjectPlanService.updateById(nursingProjectPlan));
    }

    /**
     * 删除护理计划和项目关联
     */
    @ApiOperation("删除护理计划和项目关联")
    @PreAuthorize("@ss.hasPermi('nursing:projectPlan:remove')")
    @Log(title = "护理计划和项目关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable Integer id)
    {
        return toAjax(nursingProjectPlanService.removeById(id));
    }
}
